package controller;

import javax.swing.JButton;

import model.Flight;
import model.FlightContainer;
import model.Hotel;
import model.HotelContainer;
import view.MainAppFrame;
import forms.FlightForm;
import forms.HotelForm;

/**
 * 
 * @author Ceren BOZKURT
 * @author Duygu AYAN
 * @author Pelin OZTURK
 */
public class TravelManagementController {

	// ATTRIBUTES
	public JButton btnSearchFlights;
	public JButton btnSearchHotels;

	// The Controller needs to interact with both the Model and View.
	public FlightContainer flightContainer = new FlightContainer();
	public HotelContainer hotelContainer = new HotelContainer();
	private MainAppFrame m_view;

	// CONSTRUCTOR
	public TravelManagementController(MainAppFrame m_view) {
		super();
		this.m_view = m_view;
	}

	// METHODS
	public void showFlightResults(){
		Flight userInputFlight = m_view.getUserInputFlight();
		FlightForm flightForm = flightContainer.searchFlight(userInputFlight);
		m_view.showFlightResults(flightForm);
	}

	public void showHotelResults(){
		Hotel userInputHotel = m_view.getUserInputHotel();
		HotelForm hotelForm = hotelContainer.searchHotel(userInputHotel);
		m_view.showHotelResults(hotelForm);
	}

	// At MainAppFrame
	//	public Flight getUserInputFlight() {
	//		Flight flight;
	//		String departure = m_view.getCbDeparture().getSelectedItem().toString();
	//		String arrival = m_view.getCbArrival().getSelectedItem().toString();
	//		SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
	//		String departureDate = formatter.format(m_view.getDpDepartureDate().getDate());
	//		//Calendar cal = new GregorianCalendar(dpDepartureDate.getDate().getYear(),dpDepartureDate.getDate().getMonth(),dpDepartureDate.getDate().getDate());
	//		//System.out.println(cal.get);
	//		//String departureDate = new Integer(dpDepartureDate.getDate().getDay()).toString()+"."+new Integer(dpDepartureDate.getDate().getMonth()).toString()+"."+new Integer(dpDepartureDate.getDate().getYear()).toString();
	//		flight = new Flight(departure,arrival,departureDate);
	//		return flight;
	//	}

	// At MainAppFrame
	//	public Hotel getUserInputHotel() {
	//		Hotel hotel;
	//		String location = m_view.getCbLocation().getSelectedItem().toString();
	//		String quality = m_view.getCbQuality().getSelectedItem().toString();
	//		int priceRange = m_view.getCbPriceRange().getSelectedIndex(); // getSelectedItem().toString();
	//		hotel = new Hotel(location, quality, priceRange);
	//		return hotel;
	//	}

}
